/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: javase202202 - Arrs1
 * <p>Powered by Lisi On 2022-06-06 17:12:14
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class Arrs1 {
    public static void main(String[] args) {
        var n = new Integer[]{10, 20, 30, 5, 2, 12, 1};
        System.out.println(Arrays.toString(n));
        Arrays.sort(n, (x, y) -> y - x);
        System.out.println(Arrays.toString(n));

        //Arrays.sort(n, (x, y) -> Math.random() > .5 ? 1 : -1);
        //System.out.println(Arrays.toString(n));


        Random rand = new Random();
        for (int i = 1; i <= 1250; i++) {
            int a = rand.nextInt(n.length);
            int b = rand.nextInt(n.length);
            if (a == b) {
                continue;
            } else {
                int t = n[a];
                n[a] = n[b];
                n[b] = t;
            }
        }
        System.out.println(Arrays.toString(n));

    }
}
